\hypertarget{general__io_2main_8c}{
\section{general\_\-io/main.c File Reference}
\label{general__io_2main_8c}\index{general\_\-io/main.c@{general\_\-io/main.c}}
}
Main file of the General I/O card.  


{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$avr/io.h$>$}\par
{\tt \#include $<$avr/interrupt.h$>$}\par
{\tt \#include \char`\"{}main.h\char`\"{}}\par
{\tt \#include \char`\"{}board.h\char`\"{}}\par
{\tt \#include \char`\"{}init.h\char`\"{}}\par
{\tt \#include \char`\"{}../i2c.h\char`\"{}}\par
{\tt \#include \char`\"{}../delay.h\char`\"{}}\par
{\tt \#include \char`\"{}../wmv\_\-bus/bus.h\char`\"{}}\par
{\tt \#include \char`\"{}../wmv\_\-bus/bus\_\-ping.h\char`\"{}}\par
{\tt \#include \char`\"{}../wmv\_\-bus/bus\_\-rx\_\-queue.h\char`\"{}}\par
{\tt \#include \char`\"{}../wmv\_\-bus/bus\_\-tx\_\-queue.h\char`\"{}}\par
{\tt \#include \char`\"{}../wmv\_\-bus/bus\_\-commands.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hypertarget{general__io_2main_8c_e215e459098d842339b421dfc696989a}{
void \hyperlink{general__io_2main_8c_e215e459098d842339b421dfc696989a}{bus\_\-parse\_\-message} (void)}
\label{general__io_2main_8c_e215e459098d842339b421dfc696989a}

\begin{CompactList}\small\item\em Parse a message and exectute the proper commands This function is used to parse a message that was receieved on the bus that is located in the RX queue. \item\end{CompactList}\item 
unsigned char \hyperlink{general__io_2main_8c_d9e4e537759b32f2e6c232282b310677}{read\_\-ext\_\-addr} (void)
\begin{CompactList}\small\item\em Read the external DIP-switch. This function is used to read the external offset address on the General I/O card. \item\end{CompactList}\item 
int \hyperlink{general__io_2main_8c_840291bc02cba5474a4cb46a9b9566fe}{main} (void)
\item 
\hypertarget{general__io_2main_8c_6761d1f0a3be0ccdce714cb9c7cbdcc3}{
\hyperlink{general__io_2main_8c_6761d1f0a3be0ccdce714cb9c7cbdcc3}{ISR} (SIG\_\-OUTPUT\_\-COMPARE0)}
\label{general__io_2main_8c_6761d1f0a3be0ccdce714cb9c7cbdcc3}

\begin{CompactList}\small\item\em Output compare 0 interrupt - \char`\"{}called\char`\"{} with 1ms intervals. \item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
\hypertarget{general__io_2main_8c_f6c8a57664747c58a8c7361bbaef1281}{
unsigned char \hyperlink{general__io_2main_8c_f6c8a57664747c58a8c7361bbaef1281}{device\_\-id}}
\label{general__io_2main_8c_f6c8a57664747c58a8c7361bbaef1281}

\begin{CompactList}\small\item\em Contains info of the driver type. \item\end{CompactList}\item 
\hypertarget{general__io_2main_8c_f9cecdd922128d66e61541bac7dd6a56}{
unsigned int \hyperlink{general__io_2main_8c_f9cecdd922128d66e61541bac7dd6a56}{counter\_\-compare0} = 0}
\label{general__io_2main_8c_f9cecdd922128d66e61541bac7dd6a56}

\begin{CompactList}\small\item\em Counter to keep track of the numbers of ticks from timer0. \item\end{CompactList}\item 
\hypertarget{general__io_2main_8c_74878c125411662a50fddaae20fef5fc}{
unsigned int \hyperlink{general__io_2main_8c_74878c125411662a50fddaae20fef5fc}{counter\_\-sync} = 0}
\label{general__io_2main_8c_74878c125411662a50fddaae20fef5fc}

\begin{CompactList}\small\item\em Counter to keep track of the time elapsed since the last sync message was sent. \item\end{CompactList}\item 
\hypertarget{general__io_2main_8c_358c5643835429082b4aeea9c0365896}{
unsigned int \hyperlink{general__io_2main_8c_358c5643835429082b4aeea9c0365896}{counter\_\-ping\_\-interval} = 0}
\label{general__io_2main_8c_358c5643835429082b4aeea9c0365896}

\begin{CompactList}\small\item\em Counter to keep track of when to send a ping out on the bus. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Main file of the General I/O card. 

\begin{Desc}
\item[Author:]Mikael Larsmark, SM2WMV \end{Desc}
\begin{Desc}
\item[Date:]2010-05-18 

\begin{Code}\begin{verbatim} #include "general_io/main.c" 
\end{verbatim}
\end{Code}

 \end{Desc}


Definition in file \hyperlink{general__io_2main_8c-source}{main.c}.

\subsection{Function Documentation}
\hypertarget{general__io_2main_8c_840291bc02cba5474a4cb46a9b9566fe}{
\index{general\_\-io/main.c@{general\_\-io/main.c}!main@{main}}
\index{main@{main}!general_io/main.c@{general\_\-io/main.c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (void)}}
\label{general__io_2main_8c_840291bc02cba5474a4cb46a9b9566fe}


Main function of the General I/O 

Definition at line 77 of file main.c.

References bus\_\-add\_\-tx\_\-message(), bus\_\-allowed\_\-to\_\-send(), BUS\_\-BROADCAST\_\-ADDR, bus\_\-check\_\-tx\_\-status(), BUS\_\-CMD\_\-PING, BUS\_\-CMD\_\-SYNC, BUS\_\-DEVICE\_\-STATUS\_\-MESSAGE\_\-INTERVAL, bus\_\-get\_\-address(), bus\_\-get\_\-device\_\-count(), bus\_\-init(), bus\_\-is\_\-master(), BUS\_\-MASTER\_\-SYNC\_\-INTERVAL, bus\_\-parse\_\-message(), bus\_\-set\_\-address(), bus\_\-set\_\-is\_\-master(), counter\_\-ping\_\-interval, counter\_\-sync, DEF\_\-NR\_\-DEVICES, DEFAULT\_\-STARTUP\_\-DELAY, device\_\-count, device\_\-id, DEVICE\_\-ID\_\-GENERAL\_\-IO, init\_\-ports(), init\_\-timer\_\-0(), init\_\-timer\_\-2(), read\_\-ext\_\-addr(), rx\_\-queue\_\-is\_\-empty(), and tx\_\-queue\_\-is\_\-empty().\hypertarget{general__io_2main_8c_d9e4e537759b32f2e6c232282b310677}{
\index{general\_\-io/main.c@{general\_\-io/main.c}!read\_\-ext\_\-addr@{read\_\-ext\_\-addr}}
\index{read\_\-ext\_\-addr@{read\_\-ext\_\-addr}!general_io/main.c@{general\_\-io/main.c}}
\subsubsection[{read\_\-ext\_\-addr}]{\setlength{\rightskip}{0pt plus 5cm}unsigned char read\_\-ext\_\-addr (void)}}
\label{general__io_2main_8c_d9e4e537759b32f2e6c232282b310677}


Read the external DIP-switch. This function is used to read the external offset address on the General I/O card. 

\begin{Desc}
\item[Returns:]The address of the external DIP-switch \end{Desc}


Definition at line 72 of file main.c.